package com.shaozi.nc.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shaozi.nc.data.model.CompanyInfoModel;
import com.shaozi.nc.web.action.base.BaseActionImpl;
import com.shaozi.lib.core.ActionRetBean;

@Controller
@RequestMapping(value = "/account")
public class AccountAction extends BaseActionImpl {
	private static final Logger logger = Logger.getLogger(AccountAction.class);

	public AccountAction() {

	}

	@RequestMapping(value = "/userStatus", method = RequestMethod.POST)
	@ResponseBody
	public ActionRetBean userStatusChanged(HttpServletRequest req, HttpServletResponse res, String sig) {
		return null;
	}

//	@RequestMapping(value = "/userInfoChanged", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
//	@ResponseBody
//	public ActionRetBean userInfoChanged(HttpServletRequest req, HttpServletResponse res,
//			@RequestBody CompanyInfoChangeEvent eventBean) {
//		ActionRetBean retBean = new ActionRetBean();
//		if (!StringUtils.isEmpty(eventBean.getCompanyId())) {
//			UserInfoChangeEventProducer producer = (UserInfoChangeEventProducer) BeanUtils
//					.getBean("userInfoChangeEventProducer");
//			producer.pushMsg(eventBean);
//		} else {
//			retBean.setCode(-1);
//			retBean.setMsg("uid/company_id/username can not be null!");
//		}
//		return retBean;
//	}

	@RequestMapping(value = "/companyInfoSync", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
	@ResponseBody
	public ActionRetBean companyInfoSync(HttpServletRequest req, HttpServletResponse res,
			@RequestBody CompanyInfoModel eventBean) {
		ActionRetBean retBean = new ActionRetBean();
		if (!StringUtils.isEmpty(eventBean.getCompanyName()) && !StringUtils.isEmpty(eventBean.getCompanyId())) {
//			CompanyInfoChangeEventProducer producer = (CompanyInfoChangeEventProducer) BeanUtils
//					.getBean("companyInfoChangeEventProducer");
//			producer.pushMsg(eventBean);
		} else {
			retBean.setCode(-1);
			retBean.setMsg("company_id/company name can not be null!");
		}
		return retBean;
	}
}
